#include <string.h>
#include <ctype.h>
#include <stddef.h>

int strncasecmp(const char *s1, const char *s2, size_t n)
{
	while(n > 0 
		&& toupper((unsigned char)*s1) == toupper((unsigned char)*s2))
	{
		if(*s1 == '\0')
			return 0;
		s1++;
		s2++;
		n--;
	}
	if(n == 0)
		return 0;
	return toupper((unsigned char)*s1) - toupper((unsigned char)*s2);
}